import React from 'react';
import GopherProps from '../objects/internal/GopherProps';
import { useTranslation } from 'react-i18next';
import AsyncPaginatedTable from './AsyncPaginatedTable';

export interface StaffTableProps extends GopherProps {
	onSelection: (key: React.Key[]) => void;
}

export default function StaffTable(props: StaffTableProps) {
	const {t} = useTranslation();

	const dataFormat = [
		{
			title: t('table-header-username'),
			dataIndex: 'username',
		},
		{
			title: t('table-header-display-name'),
			dataIndex: 'displayName',
		},
		{
			title: t('table-header-gender'),
			dataIndex: 'gender',
		},
		{
			title: t('table-header-role'),
			dataIndex: 'role',
		},
		{
			title: t('table-header-register-time'),
			dataIndex: 'registerTime',
		},
		{
			title: t('table-header-clock-in-time'),
			dataIndex: 'clockInTime',
		},
		{
			title: t('table-header-notes'),
			dataIndex: 'notes',
		},
	];

	return (
		<>
			<AsyncPaginatedTable rowKey={'username'} dataFormat={dataFormat} fetch={props.gopher.listStaffConverted.bind(props.gopher)}
								 onSelection={props.onSelection} gopher={props.gopher}/>
		</>
	);
}
